package com.qfjy.homework.liqingyu;

import java.util.HashMap;

/**
 * @ProjectName: java2204-ch9-git-boot
 * @ClassName: ShapeFactory
 * @Author: Liqingyu
 * @Date: 2022/11/10 19:14
 */
public class ShapeFactory {
    private static final HashMap<String, Shape> map = new HashMap<>();

    public static Shape getCircle(String color) {
        Circle circle = (Circle) map.get(color);
        if (circle == null) {
            circle = new Circle(color);
            map.put(color, circle);
            System.out.println("创建的圆的颜色是：" + color);
        }
        return circle;
    }
}
